namespace Digitalmes.Application.Mes;

/// <summary>
/// 生产工单表
/// </summary>
public sealed class ProdWoDto : Dto
{
    /// <summary>
    /// 工单单号
    /// </summary>
    [Required, NotNull]
    [StringLength(32)]
    public string? Wo { get; set; } 

    /// <summary>
    /// 产品Id
    /// </summary>
    public long ProductId { get; set; }

    /// <summary>
    /// 产品（成品）信息
    /// </summary>
    public MdItemDto? Product { get; set; }

    /// <summary>
    /// 产品代码
    /// </summary>
    [Required, NotNull]
    [StringLength(64)]
    public string? ProductCode { get; set; } 

    /// <summary>
    /// 总数量
    /// </summary>
    public int TotalQty { get; set; }

    /// <summary>
    /// 计划开始时间
    /// </summary>
    public DateTime PlanStartTime { get; set; }

    /// <summary>
    /// 计划结束时间
    /// </summary>
    public DateTime PlanEndTime { get; set; }

    /// <summary>
    /// 实际开始时间
    /// </summary>
    public DateTime? ActualStartTime { get; set; } 

    /// <summary>
    /// 实际结束时间
    /// </summary>
    public DateTime? ActualEndTime { get; set; } 

    /// <summary>
    /// 工单来源（本地创建、ERP下发）
    /// </summary>
    public WoSourceEnum Source { get; set; }

    public string? SourceDesc => Source.Description();

    /// <summary>
    /// 批次号
    /// </summary>
    public string? BatchNo { get; set; } 

    /// <summary>
    /// 单据状态
    /// </summary>
    public WoStatusEnum Status { get; set; }

    public string? StatusDesc => Status.Description();

    /// <summary>
    /// 上一次单据切换状态
    /// </summary>
    public WoStatusEnum LastStatus { get; set; }

    /// <summary>
    /// 上线数量
    /// </summary>
    public int OnlineQty { get; set; }

    /// <summary>
    /// 完工数量
    /// </summary>
    public int CompletedQty { get; set; }

    /// <summary>
    /// 合格数量
    /// </summary>
    public int QualifiedQty { get; set; }

    /// <summary>
    /// 不合格数量
    /// </summary>
    public int UnqualifiedQty { get; set; }

    /// <summary>
    /// 报废数量
    /// </summary>
    public int ScrapQty { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    public string? CreateUser { get; set; } 

    /// <summary>
    /// 修改时间
    /// </summary>
    public DateTime? UpdateTime { get; set; } 

    /// <summary>
    /// 修改人
    /// </summary>
    public string? UpdateUser { get; set; } 
}